import java.util.ArrayList;
import java.util.Scanner;

public class J {

	private static int rellenar(ArrayList<Boolean> a, Scanner in) {
		int digitos = 0;
		for (int i = 0; i < 9; i++) {
			String l = in.nextLine();
			for (int j = 0; j < 9; j++) {
				if (l.charAt(j) == '-') {
					a.add(true);
				} else {
					a.add(false);
					digitos++;
				}
			}
		}
		return digitos;

	}

	private static boolean comprobar(ArrayList<Boolean> a) {
		// System.out.println(a);//DEBUG
		boolean ok = true;
		int i = 0;
		while (ok && i < 41) {
			ok = (a.get(i) == a.get(80 - i));
			i++;
		}
		return ok;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long nCasos = in.nextLong();
		in.nextLine();
		for (long n = 0; n < nCasos; n++) {
			in.nextLine();
			ArrayList<Boolean> a = new ArrayList<Boolean>();
			int digitos = rellenar(a, in);
			System.out.println((digitos<=32 && comprobar(a)) ? "SI" : "NO");
		}
	}

}
